// 1.导入Redis模块
const { createClient } = require('redis')
const { REDIS_CONFIG } = require('../config/db')

// 2.创建连接并监听错误
const redisClient = createClient({ ...REDIS_CONFIG, legacyMode: true })
redisClient.on('error', (err) => console.log('Redis Client Error', err))

// 3.建立Redis连接
redisClient.connect().catch(console.error)

module.exports = redisClient
